<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>{&SITE_TITLE}</title>
    <link href="__PUBLIC__/admin/css/layout.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="../Public/Js/jquery-1.2.6.js" ></script>

	<script type="text/javascript">
        $( document ).ready( function(){
              $( "#smiletype option[value='{$smiletype}']" ).attr( 'selected',true );
            })
      function addCategory( name ){
        $.post( "__URL__/doAddCategory",{name:name},function( id ){
            if( id != -1 ){
                var html = "<tr class=\"cell altbg1\" id = \"category"+id+"\">\
                    <td><input type=\"checkbox\" class=\"checkbox\" name=\"id[]\" value=\""+id+"\" /></td>\
                    <td>"+id+"</td>\
                    <td ><input type=\"input\" name=\"name["+id+"]\" class=\"txt\" id=\"c"+id+"\" value=\""+name+"\" /></td>\
                    <td><button type=\"button\" onclick=\"c.del("+id+")\">删除</button></td>\
                    </tr>\
                ";
                $( 'tr['+'id=\'category\']' ).before( html );
            }else{
              alert( "添加分类失败" );
            }
            });
      }


		var ctrl = function(name){
			this.elements = document.getElementsByName('id[]');
			this.length = this.elements.length;
		}

		ctrl.prototype = {
			reverse:function(){
				for(i=0;i<this.length;i++){
					this.elements[i].checked= !this.elements[i].checked;
				}
			},
			all:function(){
				for(i=0;i<this.length;i++){
					this.elements[i].checked = true;
				}
			},
			unAll:function(){
				for(i=0;i<this.length;i++){
					this.elements[i].checked = false;
				}
			},
			toggle:function(obj){
				this[obj.checked ? 'all' : 'unAll']();
			},
			del:function(id){
				if(id==undefined){
					id = [];
					for(i=0;i<this.length;i++){
						this.elements[i].checked && id.push(this.elements[i].value);
					}
					id = id.join(',');
				}
                alert( id );
        //ajax删除id
        $.post( '__URL__/doDeleteCategory',{id:id},function( text ){
            //返回1，是只是选择了一个id,返回2，选择了多个
            if( text == 1 ){
                 $( 'tr['+'id=\'category'+id+'\']' ).remove();
              }else if( text == 2 ){
                  var id_list = id.split( ',' );   
                  for (var j=0 ; j< id_list.length ; j++   ){
                      $( 'tr['+'id=\'category'+id_list[j]+'\']' ).remove();
                  }
              }else{
                alert( '删除失败' );
              }
            });
			},
			edit:function(id){
				alert('您选择了id为:'+id);
			}
		}
		var c = null;
</script>
        
  </head>
  <body>
      <div id="container">
                        <div class="tab">
                                <ul>
                                    <li> <a class="on" href="__URL__/index/">Bug列表</a></li>
                                    <li><a href="__URL__/category/">类型管理</a></li>
                                    <li><a href="__URL__/edition/">版本管理</a></li>
                                </ul>
                        </div>



        <form action="__URL__/" method="post">
          <table class="tableborder" width="100%">
            <tbody>
              <tr class="top">
                <td class="border" colspan="8"></td>
              </tr>
              <tr>
                <th class="header" colspan="8">Bug管理</th>
              </tr>
              <tr class="label">
                <th style="width:50px;"><input type="checkbox" class="checkbox" onclick="c.toggle(this)" />删？</th>
                <th style="width:60px;">Bugid</th>
                <th style="width:250px;">标题</th>
                <th>版本</th>
                <th>类型</th>
                <th>状态</th>
                <th>发布时间</th>
                <th>操作</th>
              </tr>

<volist id="vo" name="data">
              <tr class="cell altbg1">
              	<td><input type="checkbox" class="checkbox" name="id[]" value="{$vo.id}" /></td>
              	<td>{$vo.id}</td>
              	<td><a href="__APP__/Bug/view/id/{$vo.id}" target="_blank">{$vo.title}</a></td>
              	<td>{$vo.edition|getEditionName}</td>
              	<td>{$vo.catid|getCategoryName}</td>
              	<td>{$vo.state}</td>
              	<td>{$vo.cTime|friendlyDate}</td>
              	<td>删除</td>
              </tr>
</volist>             
              <tr id = "category">
                <td class="footer" colspan="8">
                  <button type="button" onclick="c.all()">全选</button>
                  <button type="button" onclick="c.unAll()">全不选</button>
                  <button type="button" onclick="c.reverse()">反选</button>
                  <button type="button" onclick="c.del()">删除</button>
                  <button type="submit" >提交</button>
                </td>
              </tr>
              <tr class="bottom">
                <td class="border" colspan="8">&nbsp;</td>
              </tr>
            </tbody>
          </table>
    <script type="text/javascript">
      c = new ctrl('id[]');
      $( "#allorder option[@value='{$allorder}']" ).attr( 'selected','selected' );
    </script>

        </form>
      </div>
    </body>
</html>
